package com.ys.controller.web.account;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import com.ys.config.MenuId;
import com.ys.entity.account.TbNeedPayType;
import com.ys.service.sys.CommonApiService;
import com.ys.vo.W;

/**
 * 预支类型维护
 */
@Controller
@RequestMapping("/web/account/tbNeedPayType")
public class WebTbNeedPayTypeController {
	private static final Logger logger = LoggerFactory.getLogger(WebTbNeedPayTypeController.class);

	@Autowired
	private CommonApiService<TbNeedPayType> commonApiService;
	
	/*
	 * 新增
	 */
	@RequiresPermissions("tbNeedPayType:add")
	@GetMapping("/toAdd")
	public String toAdd(Model model, HttpServletRequest request, HttpServletResponse response){
		try {
			TbNeedPayType entity = new TbNeedPayType();
			entity.setCode(commonApiService.getCommonNextUkey(MenuId.TB_NeedPayType, "Code"))
				.setStatus(1);
			return commonApiService.toAdd(model, entity, MenuId.TB_NeedPayType, null, null);
		} catch (Exception e) {
			e.printStackTrace();
			return W.error(model, e.getMessage());
		}
	}

    /*
     * 编辑
     */
    @GetMapping("/toEdit")
    public String toEdit(Model model, HttpServletRequest request, HttpServletResponse response, Long id) {

		try {
			return commonApiService.toEdit(model, id, new TbNeedPayType(), MenuId.TB_NeedPayType, null, null);
		} catch (Exception e) {
			e.printStackTrace();
			return W.error(model, e.getMessage());
		}
    }


    /*
     * 详情
     */
    @GetMapping("/toDetail")
    public String toDetail(Model model, HttpServletRequest request, HttpServletResponse response, Long id) {
        try {
            model.addAttribute("onProcess", 1);
            return commonApiService.toEdit(model,id, new TbNeedPayType(), MenuId.TB_NeedPayType, null, null);
        }catch (Exception e) {
            logger.error("详情页面出错：",e.getMessage(),e);
            return W.error(model, e.getMessage());
        }
    }




}






